class Solution {
public:
    double Power(double base, int exponent) {
        if (!exponent)
            return 1;
        else if (!base)
            return 0;
        bool flag = true;
        double ret = base;
        if (exponent < 0)
        {
            flag = false;
            exponent = -exponent;
        }
        while (--exponent)
            ret *= base;
        if (!flag)
            ret = 1 / ret;
        return ret;
    }
};